package com.sunlands.qdcy.tongzhuo.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Objects;

import static com.sunlands.qdcy.tongzhuo.web.DiaryController.MAX_UPLOAD_IMAGES;

/**
 * @author anjl
 * @date 2019/5/3011:14
 */
@ApiModel(value = "日记发布传入对象")
@Data
public class DiaryDTO {

    @ApiModelProperty(value = "日记内容")
    private String content;

    @ApiModelProperty(value = "图片内容，多个逗号分隔")
    private List<String> imgUrls;

//    @ApiModelProperty(value = "视频内容，多个逗号分隔")
//    private List<String> videoUrls;

    @ApiModelProperty(value = "话题id")
    private Long topicId;

    public void validate(){


        if(StringUtils.isBlank(content)){
            throw new IllegalArgumentException("content 不能为空！");
        }else if(Objects.nonNull(imgUrls) && imgUrls.size() > MAX_UPLOAD_IMAGES){
            throw new IllegalArgumentException("最多只能上传" + MAX_UPLOAD_IMAGES + "张图片！");
        }
    }

}
